package net.livingflow.web.resource;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import net.livingflow.model.SharedData;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @author xueqiang.mi
 * @since 2010-12-19
 */
@Path("/data")
@Component
@Scope(BeanDefinition.SCOPE_SINGLETON)
public class SharedDataResource extends BaseResource {

	@GET
	@Path("shared/lattest")
	@Produces("text/plain")
	public String getLattestSharedData() {
		List<SharedData> list = sharedDataService.lattest();
		StringBuilder sb = new StringBuilder();
		for (SharedData sd : list) {
			sb.append(sd.getCrtDate() + "\n" + sd.getContent().getValue() + "\n");
		}
		return sb.toString();
	}
}
